#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import uuid
from datetime import datetime

from com.chenxiaojie.dao.orm import Model, StringField, TextField

"""
CREATE TABLE `_blog` (
  `_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `id` char(32) NOT NULL DEFAULT '',
  `user_id` char(32) NOT NULL DEFAULT '',
  `title` varchar(256) NOT NULL DEFAULT '',
  `summary` varchar(512) NOT NULL DEFAULT '',
  `content` text NOT NULL,
  `created_at` datetime NOT NULL DEFAULT '2018-12-12 00:00:00',
  PRIMARY KEY (`_id`),
  UNIQUE KEY `uni_id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
"""


class Blog(Model):
    __table__ = '_blog'

    id = StringField(primary_key=True, default=lambda: uuid.uuid4().hex)
    user_id = StringField()
    title = StringField()
    summary = StringField()
    content = TextField()
    created_at = StringField(default=lambda: datetime.now().strftime('%Y-%m-%d %H:%M:%S'))